package com.example.downloaddemo.download;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;

import android.net.http.AndroidHttpClient;

import com.example.downloaddemo.download.bean.DownloadInfo;

public class DownloadTask {
	private DownloadInfo mDownloadInfo;
	private long mContentLength;
	private long mDownloadedLength;
	
	public long getDownloadedLength() {
		return mDownloadedLength;
	}

	public void setDownloadedLength(long mDownloadedLength) {
		this.mDownloadedLength = mDownloadedLength;
	}

	private String mSaveFile;

	public DownloadTask(DownloadInfo info) {
		mDownloadInfo = info;
		init();
	}

	private void init() {
		String url = mDownloadInfo.downloadUrl;
		AndroidHttpClient client = AndroidHttpClient.newInstance(null);
		HttpGet get = new HttpGet(url);
		try {
			HttpResponse response = client.execute(get);
			mContentLength = response.getEntity().getContentLength();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public DownloadInfo getDownloadInfo() {
		return mDownloadInfo;
	}

	public void setmDownloadInfo(DownloadInfo downloadInfo) {
		this.mDownloadInfo = downloadInfo;
	}

	public long getmContentLength() {
		return mContentLength;
	}

	public String getmSaveFile() {
		return mSaveFile;
	}

	public void setmSaveFile(String saveFile) {
		this.mSaveFile = saveFile;
	}
}
